<?php
/*
	本插件：$this->model('model')->方法名();
	其他地方调用：model('jy_jifenyou/model')->方法名();
*/
namespace jy_jifenyou;
defined('BY_JYA') or exit('error');
class model extends \plugin{
	public function signday($isexi=false){
		$date=date('ymd');
		$check=pdo_getcolumn('core_qiandao',array('mid'=>$_SESSION['uid'],'date'=>$date,'uniacid'=>$_SESSION['uniacid']),'id');
		if($check){
			if($isexi){
				exi('已经签到，无需重复签到！','error');
			}else{
				return false;
			}
		}
		//插入签到数据
		$insert=array(
			'mid'=>$_SESSION['uid'],
			'date'=>$date,
			'uniacid'=>$_SESSION['uniacid'],
			'createtime'=>TIMESTAMP
		);
		pdo_insert('core_qiandao',$insert);
		//统计连续签到，先判断昨天是否签到，如果未签到则重新开始统计。否则添加连续签到次数
		$credit=$return['pluginset']['day1'];
		if($credit){
			cfc('core')->member_credit($_SESSION['uid'],'credit1',intval($credit),true,'jy_jifenyou','积分优品签到奖励');
		}
		$_SESSION['issign']=true;
		return true;
	}
	public function signstart($isexi=false){
		$date=date('ymd');
		$check=pdo_getcolumn('core_qiandao',array('mid'=>$_SESSION['uid'],'plugin_name'=>'jy_jifenyou','isnew'=>1,'uniacid'=>$_SESSION['uniacid']),'id');
		if($check || $_SESSION['isgetjifen'] || !$_SESSION['uid']){
			return false;
		}
		//插入签到数据
		$insert=array(
			'mid'=>$_SESSION['uid'],
			'date'=>$date,
			'uniacid'=>$_SESSION['uniacid'],
			'plugin_name'=>'jy_jifenyou',
			'isnew'=>1,
			'createtime'=>TIMESTAMP
		);
		pdo_insert('core_qiandao',$insert);
		//统计连续签到，先判断昨天是否签到，如果未签到则重新开始统计。否则添加连续签到次数
		$credit=$return['pluginset']['jifen'];
		if($credit){
			cfc('core')->member_credit($_SESSION['uid'],'credit1',intval($credit),true,'jy_jifenyou','积分优品新会员奖励');
		}
		$_SESSION['isgetjifen']=true;
		return true;
	}
}
?>